package com.ladybug.flow.common.config;

import com.ladybug.flow.common.resolvers.LoginUserResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
* @description: WEB配置
* @author long
* @date 2022/10/14 17:02
* @version 1.0
*/
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
    /*
     * @Author long
     * @Description 将LoginUser解析器注入到SpirngMVC
     * @Date 16:51 2022/10/17
     * @Param [resolvers]
     * @return void
     **/
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new LoginUserResolver());
    }
/*    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //是否发送Cookie
                .allowCredentials(true)
                //放行哪些原始域
                .allowedOrigins("*")
                .allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"})
                .allowedHeaders("*")
                .exposedHeaders("*");
    }*/
}
